package com.cloud.common.config;

import io.minio.MinioClient;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

@Data
@Component
public class MinioConfiguration {

    // 服务ip/域名地址
    @Value("${minio.endpoint}")
    private String endpoint;

    // 服务端口
    @Value("${minio.port}")
    private int port;

    // Minio 账户
    @Value("${minio.access-key}")
    private String accessKey;

    // Minio 密码
    @Value("${minio.secret-key}")
    private String secretKey;

    // 如果是true,则用的是https而不是http,默认值是true
    @Value("${minio.secure}")
    private Boolean secure;

    @Bean
    public MinioClient getMinioClient() {
        return MinioClient.builder().endpoint(endpoint, port, secure).credentials(accessKey, secretKey).build();
    }

}

